package red.action;

import com.opensymphony.xwork2.Action;
import org.apache.struts2.ServletActionContext;
import red.model.ResModel;
import red.model.UserModel;
import red.service.LoginService;
import red.service.impl.LoginServiceImpl;
import red.util.BaseAction;
import red.util.Model;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

public class LoginAction extends BaseAction {
    private LoginService loginService=new LoginServiceImpl();
    private UserModel userModel;
    private List<UserModel> userModels;
    private ResModel resModel;

    public ResModel getResModel() {
        return resModel;
    }

    public UserModel getUserModel() {
        return userModel;
    }


    public List<UserModel> getUserModels() {
        return userModels;
    }

   public String loginuser(){
       HttpServletRequest request = ServletActionContext.getRequest();
       String name = request.getParameter("user_name");
       String psd = request.getParameter("password");
       request.getSession().setAttribute("username",name);
       Model model = getParams();
       resModel = loginService.loginuser(model);
       return Action.SUCCESS;

    }

    public String getUser(){
        Model model = getParams();
        return Action.SUCCESS;
    }
}
